@using Extension
@inherits BlazorApp.Pages.Common.DrawerPageBase<k8s.Models.V1Pod>
@if (_podItem != null)
{
    <GridRow>
        <GridCol>
            <SimpleSelect Style="width:250px;" DefaultValue="@_podItem.Spec.Containers[0].Name" OnSelectedItemChanged="OnContainerSelectChanged">

                <SelectOptions>
                    @foreach (var c in _podItem.Spec.Containers)
                    {
                        <SimpleSelectOption Value="@c.Name" Label="@c.Name"></SimpleSelectOption>
                    }
                    <SimpleSelectOption Value="all-containers" Label="All"></SimpleSelectOption>
                </SelectOptions>
            </SimpleSelect>

            <SimpleSelect Style="width:100px;" Placeholder="@L["DateRange"]" OnSelectedItemChanged="OnSinceSelectChanged">
                <SelectOptions>
                    <SimpleSelectOption Value="1m" Label="1m"></SimpleSelectOption>
                    <SimpleSelectOption Value="5m" Label="5m"></SimpleSelectOption>
                    <SimpleSelectOption Value="10m" Label="10m"></SimpleSelectOption>
                    <SimpleSelectOption Value="30m" Label="30m"></SimpleSelectOption>
                    <SimpleSelectOption Value="45m" Label="45m"></SimpleSelectOption>
                    <SimpleSelectOption Value="1h" Label="1h"></SimpleSelectOption>
                    <SimpleSelectOption Value="specified" Label=@L["Specify"]></SimpleSelectOption>
                </SelectOptions>
            </SimpleSelect>
            <DatePicker Disabled="@(_since != "specified")" TValue="DateTime?" ShowToday="true" OnChange="@DatePickerChanged" bind-Value="@_sinceTimestamp" ShowTime="@true" Format="yyyy-MM-ddTHH:mm ss" Mask="yyyy-MM-ddTHH:mm ss" Placeholder="@($"{L["Since"]}")">
                <SuffixIcon>
                    <Icon Type="clock-circle" Theme="twotone"/>
                </SuffixIcon>
            </DatePicker>

        </GridCol>
    </GridRow>
    <GridRow>
        <GridCol>
            <Checkbox bind-Value="@_showTimestamp"
                      OnChange="@(() => _showTimestamp = !_showTimestamp)">
                @L["Show Timestamps"]
            </Checkbox>
            <Checkbox bind-Value="@_follow" OnChange="@(() => _follow = !_follow)">@L["Follow"]</Checkbox>
            <Checkbox bind-Value="@_prefix" OnChange="@(() => _prefix = !_prefix)">@L["Show Prefix"]</Checkbox>
            <Checkbox bind-Value="@_previous" OnChange="@(() => _previous = !_previous)">@L["Show Previous"]</Checkbox>
            <Checkbox bind-Value="@_ignoreErrors"
                      OnChange="@(() => _ignoreErrors = !_ignoreErrors)">
                @L["Ignore Errors"]
            </Checkbox>
            <SimpleSelect Style="width:100px;" Placeholder="@L["Pod Running Timeout"]"
                          OnSelectedItemChanged="OnTimeoutSelectChanged">
                <SelectOptions>
                    <SimpleSelectOption Value="1m" Label="1m"></SimpleSelectOption>
                    <SimpleSelectOption Value="5m" Label="5m"></SimpleSelectOption>
                    <SimpleSelectOption Value="10m" Label="10m"></SimpleSelectOption>
                </SelectOptions>
            </SimpleSelect>
            <SimpleSelect Style="width:100px;" DefaultValue="@_tail" Placeholder="Tail" OnSelectedItemChanged="OnTailSelectChanged">
                <SelectOptions>
                    <SimpleSelectOption Value="-1" Label="-1"></SimpleSelectOption>
                    <SimpleSelectOption Value="1" Label="1"></SimpleSelectOption>
                    <SimpleSelectOption Value="2" Label="2"></SimpleSelectOption>
                    <SimpleSelectOption Value="5" Label="5"></SimpleSelectOption>
                    <SimpleSelectOption Value="10" Label="10"></SimpleSelectOption>
                    <SimpleSelectOption Value="20" Label="20"></SimpleSelectOption>
                    <SimpleSelectOption Value="30" Label="30"></SimpleSelectOption>
                    <SimpleSelectOption Value="40" Label="40"></SimpleSelectOption>
                    <SimpleSelectOption Value="50" Label="50"></SimpleSelectOption>
                </SelectOptions>
            </SimpleSelect>
            <Button Type="@ButtonType.Primary" OnClick="@(() => OnOkBtnClicked())">确定</Button>
        </GridCol>
    </GridRow>
    @if (!_command.IsNullOrEmpty())
    {
        <div>
            <Alert Type="@AlertType.Success" Style="width: 100%">
                kubectl @_command
            </Alert>
        </div>
    }


    <div style="height: 100%;min-height: 300px">
        <Xterm
            @ref="_terminal"
            Options="_options"/>
    </div>
}
